<template>
  <div @click="showList" class="select" v-documentClick="changeActive">
    <span>{{ list.title }}</span>
    <i class="el-icon-caret-bottom"></i>
    <div class="list" :class="{ active: showListActive }">
      <h2>{{ list.title }}</h2>
      <div class="wrapper">
        <div class="col">
          <span
            class="mt-item"
            v-for="(item, i) in list.col1"
            :key="i"
            :data-type="item.tab"
            >{{ item.name }}</span
          >
        </div>
        <div class="col">
          <span
            class="mt-item"
            v-for="(item, i) in list.col1"
            :key="i"
            :data-type="item.tab"
            >{{ item.name }}</span
          >
        </div>
        <div class="col">
          <span
            class="mt-item"
            v-for="(item, i) in list.col1"
            :key="i"
            :data-type="item.tab"
            >{{ item.name }}</span
          >
        </div>
      </div>
    </div>
  </div>
</template>

<script>
export default {
  data() {
    return {};
  },
  props: ["list", "showListActive"],
  methods: {
    showList(e) {
      e.stopPropagation();
      this.$emit("changeListActive");
    },
    changeActive() {
      this.$emit("docuemntChangeActive", false);
    },
  },
};
</script>

<style lang="less" scoped>
.select {
  display: inline-block;
  &.disabled {
    cursor: not-allowed;
  }

  cursor: pointer;
  border-radius: 4px;
  border: 1px solid #e5e5e5;
  margin: 0 10px 0 20px;
  padding: 10px 0 10px 10px;
  vertical-align: middle;
  display: inline-block;
  width: 150px;
  height: 40px;
  position: relative;
  font-size: 14px;
  color: #666;
  box-sizing: border-box;
  i {
    color: #666;
    height: 10px;
    position: absolute;
    right: 4px;
    top: 0;
    bottom: 0;
    margin-top: auto;
    margin-bottom: auto;
  }

  .list {
    h2 {
      font-size: 16px;
      color: #ccc;
      margin-bottom: 11px;
    }
    display: none;
    position: absolute;
    cursor: default;
    top: 45px;
    left: 0;
    // width: 264px;
    height: 375px;
    padding: 20px 0 20px 15px;
    box-sizing: border-box;
    background-color: #fff;
    border: 1px solid #e5e5e5;
    box-shadow: 0 3px 5px 0 rgba(0, 0, 0, 0.1);
    border-radius: 4px;
    z-index: 1;
    &.active {
      display: block;
    }
    &::before {
      content: "";
      left: 26px;
      border-left: 6px solid transparent;
      border-right: 6px solid transparent;
      border-top: 0;
      position: absolute;
      top: -7px;
      border-bottom: 6px solid #e5e5e5;
    }
    &::after {
      content: "";
      left: 26px;
      border-left: 6px solid transparent;
      border-right: 6px solid transparent;
      border-top: 0;
      position: absolute;
      top: -5px;
      border-bottom: 6px solid #fff;
    }
    .wrapper {
      width: 264px;
      display: flex;
      &.city {
        width: 665px;
      }
      .col {
        float: left;
        .mt-item {
          cursor: pointer;
          font-size: 12px;
          color: #666;
          display: table;
          box-sizing: border-box;
          min-width: 40px;
          height: 20px;
          line-height: 20px;
          text-align: center;
          margin: 6px 38px 6px 0;
          border-radius: 9px;
          &:hover {
            background: #f4f4f4;
          }
          &.active {
            background: #13d1be;
            border-radius: 10px;
            color: #fff;
          }
        }
      }
    }
  }
  .city-choose {
    .mt-cities {
      display: none;
      position: absolute;
      cursor: default;
      top: 45px;
      left: 0;
      min-width: 150px;
      height: 375px;
      padding: 20px 0 20px 15px;
      box-sizing: border-box;
      background-color: #fff;
      border: 1px solid #e5e5e5;
      box-shadow: 0 3px 5px 0 rgba(0, 0, 0, 0.1);
      border-radius: 4px;
    }
  }
}
</style>